home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////////////////////
- // $Id: RAM.cxx,v 1.2 1994/08/22 07:35:24 bmott Exp $
- ///////////////////////////////////////////////////////////////////////////////
- // RAM.cxx
- //
- // The Random Access Memory Device
- //
- // Sim68000 "Motorola 68000 Simulator"
- // Copyright (c) 1993
- // By: Bradford W. Mott
- // July 26,1993
- //
- ///////////////////////////////////////////////////////////////////////////////
- // $Log: RAM.cxx,v $
- // Revision 1.2 1994/08/22 07:35:24 bmott
- // Changed the device argument parsing
- //
- // Revision 1.1 1994/02/18 20:12:32 bmott
- // Initial revision
- //
- ///////////////////////////////////////////////////////////////////////////////
-
- #include "String.h"
- #include "Regex.h"
-
- #include "Tools.hxx"
- #include "BasicCPU.hxx"
- #include "RAM.hxx"
-
- ///////////////////////////////////////////////////////////////////////////////
- // The class constructor
- ///////////////////////////////////////////////////////////////////////////////
- RAM::RAM(String args, BasicCPU* c)
- : BasicDevice("RAM",args,c)
- {
- Regex format("^BaseAddress=[0-9a-fA-F]+ Size=[0-9a-fA-F]+$");
-
- if(args.contains(format))
- {
- String remaining,base_arg,size_arg;
-
- remaining=args.after("BaseAddress=");
- base_arg=remaining.before(" Size=");
- size_arg=args.after(" Size=");
-
- base_address=StringToInt(base_arg)*c->Granularity();
- size=StringToInt(size_arg)*c->Granularity();
-
- if ( size > 0 )
- buffer=new unsigned char[size];
- else
- buffer=0;
- }
- else
- {
- SetErrorMessage("Invalid initialization arguments!");
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // The class destructor
- ///////////////////////////////////////////////////////////////////////////////
- RAM::~RAM()
- {
- delete[] buffer;
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // Checks to see if the address maps into this device
- ///////////////////////////////////////////////////////////////////////////////
- char RAM::CheckMapped(unsigned long addr)
- {
- if ( (addr>=base_address) && (addr<base_address+size) )
- return(1);
- else
- return(0);
- }
-
-